﻿/**
 *       Project: ServerLib
 *     Copyright: Copyright (C) 2008, Rob Kennedy
 *   Create Date: 2008-07-14 10:16 PM
 * Modified Date: 2008-07-14 10:16 PM    RK  Added comments
 *      Comments: Ignore SA1633.
 *      
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

namespace ServerLib.Core
{
    using System.Collections.Generic;
    using System.Linq;

    /// --------------------------------------------------------------------
    /// Project	 : ServerLib
    /// Class	 : NameValuePairCollection
    /// Inherits : System.Collections.Specialized.NameValueCollection
    /// --------------------------------------------------------------------
    /// <summary>
    /// Stores a collection of NameValuePair objects and enhances the base
    /// class by adding a key search method.
    /// </summary>
    /// <authorname>Rob Kennedy</authorname>
    /// <remarks></remarks>
    /// --------------------------------------------------------------------
    public class NameValuePairCollection : System.Collections.Specialized.NameValueCollection
    {
        /// <summary>
        /// Searches to see if an object exists in the collection with a specific key
        /// </summary>
        /// <param name="keyName">The key to search for</param>
        /// <returns>Returns true if the object exists with the specified key</returns>
        public bool ContainsKey(string keyName)
        {
            IEnumerable<string> keys = from string key in this.Keys
                                       where key == keyName
                                       select key;
            return (keys != null ? keys.Count<string>() > 0 : false);
        }
    }
}
